package com.cxyzy.demo

import androidx.lifecycle.Observer
import com.cxyzy.demo.base.BaseVmActivity
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : BaseVmActivity<TaskViewModel>() {

    override fun layoutResId() = R.layout.activity_main

    override fun viewModelClass() = TaskViewModel::class.java
    override fun initData() {
        queryData()
    }

    override fun observe() {
        mViewModel.run {
            todayTask.observe(this@MainActivity, Observer {
                contentTv.text = it.name
            })

            futureTask.observe(this@MainActivity, Observer {
                contentTv2.text = it.name
            })
        }
    }

    private fun queryData() {
        mViewModel.queryTodayTask()
        mViewModel.queryFutureTask()

    }
}
